<!-- saved from url=(0014)about:internet -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MultiPowUpload methods</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {
	font-family: "Courier New", Courier, monospace;
	font-style: italic;
	font-size: 100%;
}
.style3 {
	font-size: 0.7%;
	font-style: italic;
}
-->
</style></head>

<body>
 <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td width="400">

                <span class="caption">MultiPowUpload </span><span class="yellow">3.1</span>
                <br /><span class="gray">Methods</span>
            </td>
            <td>&nbsp;
                
            </td>
             <td align="char" width="200"><img src="world.jpg" align="middle" hspace="5" /><b><a target="_blank" href="http://www.element-it.com/multiple-file-upload/flash-uploader.aspx">Home
      page</a></b><br />
                          <img src="email.jpg" align="middle" hspace="5" /><b><a target="_blank" href="http://www.element-it.com/contacts.aspx">Contact
                            support</a></b> </td>
        </tr>
</table>
  
  <p class="topic"><b>MultiPowUpload object methods</b>&nbsp;
  </p><p>For more information on how to use MultiPowUpload methods see <a href="HowTo.html#javaScript">How to section. </a>
  
  </p><br />
<a href="#getId">getId</a><br>
 <br />
<a href="#getVersion">getVersion </a><br><br>
<a href="#setParameter">setParameter </a><br>    <br>	
<a href="#getParameter">getParameter </a><br>    <br>	
 
<br><a href="#getFiles">getFiles </a><br>
<br><a href="#getFilesCount">getFilesCount </a><br>
<br><a href="#getSelectedIndices">getSelectedIndices </a><br>
<br><a href="#getSelectedItems">getSelectedItems </a><br><br>

 

  <a href="#getFile">getFile </a><br>      <br>
 <a href="#getFileAt">getFileAt </a><br>    <br>
    <a href="#removeFile">removeFile </a><br>    <br>
   <a href="#removeFileAt">removeFileAt </a><br>    <br>
  <a href="#removeAll">removeAll </a><br>   <br>
  
   <a href="#sortFileList">sortFileList </a><br> <br>
	
  <a href="#uploadAll">uploadAll </a><br>
    <br>
  <a href="#uploadFiles">uploadFiles </a><br>  
    <br>

  <a href="#cancelUpload">cancelUpload </a><br>
    <br>
  <a href="#sendAndLoadVars">sendAndLoadVars </a><br>
    <br>
  
  <a href="#addPostField">addPostField </a><br><br>
  <a href="#removePostField">removePostField </a><br><br>
  
  <a href="#addFilePostField">addFilePostField </a><br>
    <br>
  <a href="#removeFilePostField">removeFilePostField </a><br>
    <br>
	<a href="#setFileDescription">setFileDescription </a><br><br>
 
 

<p class="topicLeft" name="getId" id="getId">getId</p>
<div class="signature"><p>getId()</p></div>
<p>Returns a unique identificator of MultiPowUpload instance. </p>

<p class="topicLeft" name="getVersion" id="getVersion">getVersion</p>
<div class="signature">
  <p>getVersion():String </p>
</div>
<p>Returns a string representation of the MultiPowUpload version number.</p>



<p class="topicLeft" name="setParameter" id="setParameter">setParameter</p>
<div class="signature">
  <p>setParameter(paramName:String, paramValue:String)</p>
</div>
<p>Sets a parameter at the runtime. It is possible to modify most parameters   at the runtime. MultiPowUpload reloads interface immediately.</p>
<h4>Parameters</h4>
<p><strong>paramName</strong><code>:String</code> - The name of <a href="Parameters.html">parameter</a></p>
<p><strong>paramValue</strong><code>:String</code> - Value for a specified parameter.</p>
<br />
  
<h4>Example:</h4>
<code>
function MultiPowUpload_onMovieLoad()<br />
{<br />
	MultiPowUpload.setParameter(&quot;backgroundColor&quot;,&quot;#0000FF&quot;);<br />
}
</code>

<p class="topicLeft" name="getParameter" id="getParameter">getParameter</p>
<div class="signature">
  <p>getParameter(String paramName):String</p>
</div>
<p>Returns a current value of the parameter.</p>
<h4>Parameters</h4>
<p><strong>paramName</strong><code>:String</code> - The name of <a href="Parameters.html">parameter</a></p>
<br />
  
<h4>Example:</h4>
<code>
function MultiPowUpload_onMovieLoad()<br />
{<br />
	alert(MultiPowUpload.getParameter(&quot;backgroundColor&quot;));<br />
}
</code>

<p class="topicLeft" name="getProgressInfo" id="getProgressInfo">getProgressInfo</p>
<div class="signature">
  <p>ProgressInfo getProgressInfo()</p>
</div>
<h4>Description</h4>
<p>Returns an instance of <a href="ProgressInfo.html">ProgressInfo</a> class. </p>
<h4>Example</h4>
<p><code>var progress = MultiPowUpload.getProgressInfo();</code></p>
<br/>




<p class="topicLeft" name="getFiles" id="getFiles">getFiles</p>
<div class="signature">
  <p>getFiles() ListItem[]</p>
</div>
<p>Returns an array of ListItem objects. Each object represents a file selected by a user.</p>

<p>The properties of ListItem objects are described in the <a href="ListItem.html">ListItem</a> class documentation.</p>

<h4>Example</h4>
<p>
<pre>	//Show files info	
	var list = MultiPowUpload.getFiles();
	for(var i=0; i&lt;list.length; i++)
	{
		window.alert("File " + list[i].name + " in list");
	}
</pre>
</p>
<p>&nbsp;</p>
<p class="topicLeft" name="getFilesCount" id="getFilesCount">getFilesCount</p>
<div class="signature">
  <p>getFilesCount():long</p>
</div>
<p>Returns a count of files in file list.</p>



<br />

<p class="topicLeft" name="getSelectedIndices" id="selectedIndices">getSelectedIndices</p>
<div class="signature"><p>getSelectedIndices() int[] </p></div><p>An array of Integer values.</p>

<p>Returns an array of indices of the selected items. 
<p>Return  value reflects the order in which the items were selected. If you click the second item, then the third item, and then the first item again, <code>getSelectedIndices</code> returns <code>[1,2,0]</code>. The value is <code>null</code> if nothing is selected.</p>
<h4>Example</h4>
<p>The following example retrieves the selected indices and names of a files selected:</p>
<code>
function MultiPowUpload_onListChange()<br />
{<br />
	var selIndices = MultiPowUpload.getSelectedIndices();<br />
	if(selIndices!=null)<br />
	{<br />
		for(var i=0; i&lt;selIndices.length; i++)<br />
		{<br />
			window.alert(&quot;File &quot; + MultiPowUpload.getFileAt([selIndices[i]).name + &quot; is selected in list&quot;);<br />
		}<br />
	}<br />
}
</code>

<br>
<p class="topicLeft" name="getSelectedItems" id="getSelectedItems">getSelectedItems</p>
<div class="signature"><p>getSelectedItems() ListItem[]</p></div>
<p>An array of ListItem objects.</p>

<h4>Description</h4>
<p>The function returns an array of the selected item objects. In a multiple-selection list, <code>getSelectedItems</code> lets you access the set of items selected as item objects. The value is <code>null</code> if nothing is selected.</p>

<h4>Example</h4>
<p>The following example counts total size of the selected files:</p>
<code>
function MultiPowUpload_onListChange()<br />
{<br />
	var selItems = MultiPowUpload.selectedItems();<br />
	if(selItems!=null)<br />
	{<br />
		var totalSize = 0;<br />
		for(var i=0; i&lt;selItems.length; i++)<br />
		{<br />
			totalSize += selItems[i].size;	<br />
		}<br />
		window.alert(&quot;Total size of a files selected is &quot; + totalSize + &quot; bytes.&quot;);<br />
	}
}
</code>





<br /><br />

<p class="topicLeft" name="getFile" id="getFile">getFile</p>
<div class="signature"><p>getFile(String fileId)</p></div>
<p>Returns an instance of ListItem object by a specified id.</p>
<h4>Parameters</h4>
<p><strong>fileId</strong><code>:String</code> - Identificator of the file.</p>
<br />

<p class="topicLeft" name="getFileAt" id="getFileAt">getFileAt</p>
<div class="signature"><p>getFileAt(index:Integer)</p></div>
<p>Returns an instance of ListItem object by a specified index of the file.</p>
<h4>Parameters</h4>
<p><strong>index</strong><code>:Integer</code> - An index of the file in the file list.</p>
<br />


<p class="topicLeft" name="removeFile" id="removeFile">removeFile</p>
<div class="signature"><p>removeFile(String fileId)</p></div>
<h4>Description</h4>
<p>The method removes the item with a specified identificator from <code>fileList</code>.</p>
<h4>Parameters</h4>
<p><strong>fileId</strong><code>:String</code> - Identificator of the file.</p>
<h4>Example</h4>
<p>The following code clears the selected items in a list  when a button is clicked:</p>
<code>
	function deleteSelected()<br />
	{<br />
		while(MultiPowUpload.getSelectedItems()!=null)<br />
		{<br />
			MultiPowUpload.removeFile(MultiPowUpload.getSelectedItems[0].id);<br />
		}<br />
	}
</code>

<br /><br />


<p class="topicLeft" name="removeFileAt" id="removeFileAt">removeFileAt</p>
<div class="signature"><p>removeFileAt(Integer index)</p></div>
<p>The method removes the item from <code>fileList</code> in the specified index position. The list has indices after a specified index collapses one by one.</p>
<p>Calling this method modifies the data in <code>fileList</code> object.</p>
<h4>Parameters</h4>
<p><code><em>index</em></code>&#160;A number that indicates the position of the item. The value must be greater than 0 and less than <code>fileList.length</code>.</p>
<h4>Example</h4>
<p>The following code clears the selected items in a list  when a button is clicked:</p>
<code>

	function deleteSelected()<br />
	{ <br />
		while(MultiPowUpload.getSelectedIndices()!=null)<br />
		{<br />
			MultiPowUpload.removeFileAt(MultiPowUpload.getSelectedIndices[0]);<br />
		}<br />
	}

</code>
<br /><br />

 <p class="topicLeft" name="removeAll" id="removeAll">removeAll</p>
<div class="signature"><p>removeAll()</p></div>

<h4>Description</h4>
<p>The method removes all items from the list.</p>

  <p class="topicLeft" name="sortFileList" id="sortFileList">sortFileList</p>
<div class="signature">
  <p>sortFileList(String field, String option)</p>
</div>

<p>The method sorts file list .</p>
<h4>Parameters</h4>
<p><strong>field</strong><code>:String</code> - The field to sort: NAME, SIZE or DATE <code></code></p>
<p><strong>option</strong><code>:String</code> - The order to sort: ASC or DESC.</p>
<h4>Example</h4>
<p>
  <code>
function MultiPowUpload_onAddFiles(files)<br />
{<br />
	MultiPowUpload.sortFileList("SIZE", "ASC");<br />
}<br />
  </code>
</p>


<p class="topicLeft" name="uploadAll" id="uploadAll">uploadAll</p>
<div class="signature"><p>uploadAll([String URL])</p></div>

<p>The method starts the upload of files in list  to a remote server.   The files are uploaded one by one. If there are images in the list and the value of <a href="Parameters_function.html#sendThumbnails" target="main" onclick="clickAnchor(this)">sendThumbnails</a> parameter is set to true, MultiPowUPload  will generate thumbnails for all the images and then starts the upload process. </p>
<p>The file is uploaded to the URL spesified in the <code>URL</code> parameter. The URL must be a server script configured to accept uploads.</p>


<h4>Parameters</h4>
<p><strong>URL</strong><code>:String</code> [optional] - The URL of the server script configured to handle upload through HTTP <code>POST</code> calls. If you omit this parameter, URL specified in  <code>uploadUrl</code> parameter will be used.</p>

<h4>Example:</h4>
<code>
//Upload of files to a remote server side  script after a user selects MultiPowUpload_onAddFiles() file
function <br />
{<br />
	MultiPowUpload.uploadAll("uploadfiles.aspx");<br />
}
</code>
<br /><br />

<p class="topicLeft" name="uploadFiles" id="uploadFiles">uploadFiles</p>
<div class="signature"><p>uploadFiles(int[] indeces, [String URL])</p></div>

<p>The method is similar to  <code>uploadAll()</code>, but it uploads only the files which have indeces specified in <code>indeces</code> parameter.</p>
<h4>Parameters</h4>
<p><strong>indeces</strong><code>:int[]</code> - An array of indices of the items to upload.</p>
<p><strong>URL</strong><code>:String</code> [optional] - The URL of the server script configured to handle an upload through HTTP <code>POST</code> calls. If you omit this parameter, URL specified in  <code>uploadUrl</code> parameter will be used.</p>
<h4>Example:</h4>
<p>The following example demonstates the upload of first 3 files selected by a user:</p>
<code>
function MultiPowUpload_onAddFiles()<br />
{<br />
	var indeces = [0,1,2];<br />
	MultiPowUpload.uploadFiles(indeces, "uploadfiles.aspx");<br />
}<br />
</code>



<br /><br />
  

 <p class="topicLeft" name="cancelUpload" id="cancelUpload">cancelUpload</p>
<div class="signature"><p>cancelUpload()</p></div>

<p>The method cancels the upload operation.</p>
<h4>Example</h4>
<p>The following example uploads approximately half of the files and then cancels the upload. </p>
<code>
var isCancelled = false;<br />
function MultiPowUpload_onProgress(file) <br />
{<br />
	var progress = MultiPowUpload.getProgressInfo();<br />
	if(isCancelled==false && progress.totalPercent >= 50)<br />
	{<br />
		isCancelled = true;<br />
		MultiPowUpload.cancelUpload();<br />
	}<br />
}
</code>

<br /><br />

  <p class="topicLeft" name="sendAndLoadVars" id="sendAndLoadVars">sendAndLoadVars</a> (MultiPowUpload.sendAndLoadVars method)</p>
<div class="signature">
  <p>sendAndLoadVars(String[] keys, String[] values, String URL, [String method])</p>
</div>

<p>The method posts variables to a specified URL. The server response is downloaded, parsed as variable data, and the resulting variables are placed in the <code>response</code> parameter or <code>MultiPowUpload_onLoadVars</code> event. </p>

<h4>Parameters</h4>
<p><strong>keys</strong><code>:String[]</code> - An array of variables names.</p>
<p><strong>values</strong><code>:String[]</code> - An array of variables values. Length of <code>keys</code> and <code>values</code> arrays should be the same.</p>
<p><strong>URL</strong><code>:String</code> - URL to the script which should receive variables.</p>
<p><strong>method</strong><code>:String</code> [optional] - A string; the <code>GET </code>or <code>POST</code> method of the HTTP protocol. The default value is <code>POST</code>.</p>

<h4>Example</h4>
<p>The following example uploads 2 variables to server side ASP.NET script and shows a server response.</p>
<code>
function MultiPowUpload_onMovieLoad()<br />
{<br />
	var keys=[&quot;myname&quot;, &quot;myID&quot;];<br />
	var values=[&quot;JDoe&quot;, &quot;12345&quot;];<br />
	MultiPowUpload.sendAndLoadVars(keys, values, &quot;formproc.aspx&quot;, &quot;POST&quot;);<br />
}<br />
<br />
function MultiPowUpload_onLoadVars(response)<br />
{<br />
	window.alert(response);<br />
}
</code>

<p>formproc.aspx file code:</p>
<code>
&lt;%@ Page language=&quot;c#&quot;%&gt;<br />
&lt;% <br />
Response.Write(&quot;I got your name &quot;+ Request.Form[&quot;myname&quot;] + &quot; and your ID &quot; + Request.Form[&quot;myID&quot;]);<br />
%&gt;</code>

<p class="topicLeft" name="addPostField" id="addPostField">addPostField</p>
<div class="signature">
  <p>addPostField(String paramName, String paramVal)</p>
</div>

<p>The method adds a parameter to post a request. This parameter will be posted with each uploaded file.</p>
<h4>Parameters</h4>
<p><strong>paramName</strong><code>:String</code> - name of parameter.</p>
<p><strong>paramValue</strong><code>:String</code> - value of parameter.</p>
<h4>Example</h4>
<p>
  <code>
function MultiPowUpload_onAddFiles(addedFiles)<br />
{<br />
	MultiPowUpload.addPostField("testParameter2", "Test Value 2");<br />
}
  </code>
</p>
  
<p class="topicLeft" name="removePostField" id="removePostField">removePostField</p>
<div class="signature">
  <p>removePostField(String paramName)</p>
</div>

<p>The method removes a parameter with a specified name from a post request.</p>
<h4>Parameters</h4>
<p><strong>paramName</strong><code>:String</code> - name of parameter.</p>
<h4>Example</h4>
<p>
  <code>	
	MultiPowUpload.removePostField("testParameter2");
  </code>
</p>

  
<p class="topicLeft" name="addFilePostField" id="addFilePostField">addFilePostField</p>
<div class="signature">
  <p>addFilePostField(String fileId, String paramName, String paramVal)</p>
</div>

<p>The method adds a parameter for a file specified by the fileId parameter.	This parameter will be posted to the server with a specified file.</p>
<h4>Parameters</h4>
<p><strong>fileId</strong><code>:String</code> - Identificator of file.<code></code></p>
<p><strong>paramName</strong><code>:String</code> - name of parameter.</p>
<p><strong>paramValue</strong><code>:String</code> - value of parameter.</p>
<h4>Example</h4>
<p>
  <code>
function MultiPowUpload_onAddFiles(addedFiles)<br />
{<br />
	//add post field to first added file<br />
	if(addedFiles.length > 0)<br />
		MultiPowUpload.addFilePostField(addedFiles[0].id, "testParameter", "Test Value");<br />
}
  </code>
</p>
  
<p class="topicLeft" name="removeFilePostField" id="removeFilePostField">removeFilePostField</p>
<div class="signature">
  <p>removeFilePostField(String fileId, String paramName)</p>
</div>

<p>The method removes a parameter with a &quot;paramName&quot; name from a file specified by the fileId parameter.</p>
<h4>Parameters</h4>
<p><strong>fileId</strong><code>:String</code> - Identificator of file.<code></code></p>
<p><strong>paramName</strong><code>:String</code> - name of parameter.</p>
<h4>Example</h4>
<p>
  <code>
	var fileId = MultiPowUpload.getFiles()[0].id;
	MultiPowUpload.removeFilePostField(fileId, "testParameter");
  </code>
</p>  
 
  
  
 <p class="topicLeft" name="setFileDescription" id="setFileDescription">setFileDescription</p>
<div class="signature">
  <p>setFileDescription(String fileId, String description)</p>
</div>

<p>The method sets a file description text.</p>
<h4>Parameters</h4>
<p><strong>fileId</strong><code>:String</code> - Identificator of the file.<code></code></p>
<p><strong>description</strong><code>:String</code> - New file of the description text.</p>
<h4>Example</h4>
<p>
  <code>
	var fileId = MultiPowUpload.getFiles()[0].id;
	MultiPowUpload.setFileDescription(fileId, "modified description");
  </code>
</p>
  
    

</body>
</html>